package ch.sfug.data {
	
	/**
	 * a more advaned iterator version where you can step in two directions
	 * @author mich
	 */
	public class ArrayIterator extends Iterator {
		
		public function ArrayIterator( a:Array = null ) {
			super(a);
		}
		
		/**
		 * returns true if the iterator has a previous element
		 */
		public function hasPrevious(  ):Boolean {
			if( isNaN( p ) ) {
				// start case
				return false;
			} else {
				return p - 1 >= 0;
			}
		}
		
		
		/**
		 * returns the previous element
		 */
		public function previous(  ):Object {
			if( hasPrevious() ) {
				p -= 1;
				return d[ p ];
			} else {
				return null;
			}
		}
	}
}
